# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        黄周云  
# Name:         test05
# Description:  例25.5
# Author:       ASUS
# Date:         2019/4/8
#-------------------------------------------------------------------------------


import pandas
df = pandas.read_csv("gapminder.tsv",sep="\t")
#单列分组统计
print(df.groupby('year')['lifeExp'].mean().head(3))
print("--------------------")
#多列分组统计
multi_group = df.groupby(['year','continent'])[['lifeExp','gdpPercap']].mean().head(3)
print(multi_group)
print("---------------------")
#重置索引，让每一行都显示行索引
print(multi_group.reset_index())
print("-------------------------")
#统计一个洲有多少国家
print(df.groupby('continent')['country'].nunique())




